Icd tz

Icd tz

Open in ChatGPT
Ask ChatGPT about this page
Open in Claude
Ask Claude about this page

Developer Doc: Sales Invoice Reference Update on Submit

Purpose

Automatically update invoice references for all container-related services and records when a Sales Invoice is submitted. This ensures data consistency, traceability, and workflow integration in container logistics operations.


Triggers

  • before_save: Calls validate_qty_storage_item(doc) to ensure valid quantity entries for container services.
  • on_submit: Executes update_sales_references(doc) to apply invoice references across linked documents.

Function: update_sales_references(doc)

Behavior

  • Skips processing if doc.m_bl_no is empty.
  • Skips updates if the invoice is a return (doc.is_return = 1).
  • Iterates through each item in the invoice:
    • Matches item codes with values in ICD TZ Settings.
    • Based on the item, calls specific update functions to reflect invoice references in target Doctypes.

Mappings and Updates

Item Type Target Doctype Field Updated Function Called
Transport Container Reception t_sales_invoice update_container_rec()
Shore Handling (T1/T2, 20ft/40ft) Container Reception s_sales_invoice update_container_rec()
In-Yard Booking In Yard Container Booking s_sales_invoice update_booking_refs()
Custom Verification In Yard Container Booking cv_sales_invoice update_booking_refs()
Removal Container r_sales_invoice update_container_refs()
Corridor Levy Container c_sales_invoice update_container_refs()
Storage Charges Container Dates (child table) sales_invoice update_storage_date_refs()
Any Service (if inspected) Container Inspection Detail sales_invoice update_container_insp()
  • Updates container status to "At Gatepass" where applicable.
  • Updates all Service Order records linked to the sales_order with the invoice reference.

update_container_rec(container_id, invoice_id, field)

  • Retrieves the linked Container Reception and sets the invoice reference in the specified field.

update_booking_refs(container_id, invoice_id, field)

  • Retrieves the latest submitted In Yard Container Booking and updates the given invoice reference field.

update_container_refs(container_id, invoice_id, field)

  • Directly updates invoice reference and container status in the Container record.

update_storage_date_refs(container_id, invoice_id, child_refs)

  • Iterates over the container_dates child table of the Container and updates sales_invoice for matched rows.

update_container_insp(container_id, item_code, invoice_id)

  • Updates Container Inspection Detail rows if the service matches the item being invoiced.

Dependencies

  • ICD TZ Settings must be configured with the correct item codes for all services.
  • Container, Container Reception, In Yard Container Booking, and Container Inspection must have valid links.

Notes

  • Return invoices will clear the invoice reference fields instead of setting them.
  • This logic ensures service traceability for accounting and operational reporting.
Last updated 1 week ago
Was this helpful?
Thanks!